/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.esmp.dsm.semantic.blockdiagram.provider;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.esmp.dsm.semantic.blockdiagram.util.BlockDiagramAdapterFactory;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class BlockDiagramItemProviderAdapterFactory extends BlockDiagramAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BlockDiagramItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.BlockDiagram} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BlockDiagramItemProvider blockDiagramItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.BlockDiagram}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBlockDiagramAdapter() {
		if (blockDiagramItemProvider == null) {
			blockDiagramItemProvider = new BlockDiagramItemProvider(this);
		}

		return blockDiagramItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.Block} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BlockItemProvider blockItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.Block}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBlockAdapter() {
		if (blockItemProvider == null) {
			blockItemProvider = new BlockItemProvider(this);
		}

		return blockItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.Parameter} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ParameterItemProvider parameterItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.Parameter}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createParameterAdapter() {
		if (parameterItemProvider == null) {
			parameterItemProvider = new ParameterItemProvider(this);
		}

		return parameterItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.InputPort} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InputPortItemProvider inputPortItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.InputPort}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInputPortAdapter() {
		if (inputPortItemProvider == null) {
			inputPortItemProvider = new InputPortItemProvider(this);
		}

		return inputPortItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.Connection} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ConnectionItemProvider connectionItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.Connection}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createConnectionAdapter() {
		if (connectionItemProvider == null) {
			connectionItemProvider = new ConnectionItemProvider(this);
		}

		return connectionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.OutputPort} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutputPortItemProvider outputPortItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.OutputPort}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOutputPortAdapter() {
		if (outputPortItemProvider == null) {
			outputPortItemProvider = new OutputPortItemProvider(this);
		}

		return outputPortItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.Output} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutputItemProvider outputItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.Output}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOutputAdapter() {
		if (outputItemProvider == null) {
			outputItemProvider = new OutputItemProvider(this);
		}

		return outputItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.OutputSpecification} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutputSpecificationItemProvider outputSpecificationItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.OutputSpecification}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOutputSpecificationAdapter() {
		if (outputSpecificationItemProvider == null) {
			outputSpecificationItemProvider = new OutputSpecificationItemProvider(this);
		}

		return outputSpecificationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.Input} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InputItemProvider inputItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.Input}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInputAdapter() {
		if (inputItemProvider == null) {
			inputItemProvider = new InputItemProvider(this);
		}

		return inputItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.InputSpecification} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InputSpecificationItemProvider inputSpecificationItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.InputSpecification}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInputSpecificationAdapter() {
		if (inputSpecificationItemProvider == null) {
			inputSpecificationItemProvider = new InputSpecificationItemProvider(this);
		}

		return inputSpecificationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.BlockType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BlockTypeItemProvider blockTypeItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.BlockType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBlockTypeAdapter() {
		if (blockTypeItemProvider == null) {
			blockTypeItemProvider = new BlockTypeItemProvider(this);
		}

		return blockTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.BlockCategory} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BlockCategoryItemProvider blockCategoryItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.BlockCategory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBlockCategoryAdapter() {
		if (blockCategoryItemProvider == null) {
			blockCategoryItemProvider = new BlockCategoryItemProvider(this);
		}

		return blockCategoryItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.ExpressionParameterDescriptor} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExpressionParameterDescriptorItemProvider expressionParameterDescriptorItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.ExpressionParameterDescriptor}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createExpressionParameterDescriptorAdapter() {
		if (expressionParameterDescriptorItemProvider == null) {
			expressionParameterDescriptorItemProvider = new ExpressionParameterDescriptorItemProvider(this);
		}

		return expressionParameterDescriptorItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.BooleanParameterDescriptor} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BooleanParameterDescriptorItemProvider booleanParameterDescriptorItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.BooleanParameterDescriptor}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBooleanParameterDescriptorAdapter() {
		if (booleanParameterDescriptorItemProvider == null) {
			booleanParameterDescriptorItemProvider = new BooleanParameterDescriptorItemProvider(this);
		}

		return booleanParameterDescriptorItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.EnumerationLiteral} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EnumerationLiteralItemProvider enumerationLiteralItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.EnumerationLiteral}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEnumerationLiteralAdapter() {
		if (enumerationLiteralItemProvider == null) {
			enumerationLiteralItemProvider = new EnumerationLiteralItemProvider(this);
		}

		return enumerationLiteralItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.EnumerationParameterDescriptor} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EnumerationParameterDescriptorItemProvider enumerationParameterDescriptorItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.EnumerationParameterDescriptor}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEnumerationParameterDescriptorAdapter() {
		if (enumerationParameterDescriptorItemProvider == null) {
			enumerationParameterDescriptorItemProvider = new EnumerationParameterDescriptorItemProvider(this);
		}

		return enumerationParameterDescriptorItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link org.esmp.dsm.semantic.blockdiagram.Enumeration} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EnumerationItemProvider enumerationItemProvider;

	/**
	 * This creates an adapter for a {@link org.esmp.dsm.semantic.blockdiagram.Enumeration}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEnumerationAdapter() {
		if (enumerationItemProvider == null) {
			enumerationItemProvider = new EnumerationItemProvider(this);
		}

		return enumerationItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (blockDiagramItemProvider != null) blockDiagramItemProvider.dispose();
		if (blockItemProvider != null) blockItemProvider.dispose();
		if (parameterItemProvider != null) parameterItemProvider.dispose();
		if (inputPortItemProvider != null) inputPortItemProvider.dispose();
		if (connectionItemProvider != null) connectionItemProvider.dispose();
		if (outputPortItemProvider != null) outputPortItemProvider.dispose();
		if (outputItemProvider != null) outputItemProvider.dispose();
		if (outputSpecificationItemProvider != null) outputSpecificationItemProvider.dispose();
		if (inputItemProvider != null) inputItemProvider.dispose();
		if (inputSpecificationItemProvider != null) inputSpecificationItemProvider.dispose();
		if (blockTypeItemProvider != null) blockTypeItemProvider.dispose();
		if (blockCategoryItemProvider != null) blockCategoryItemProvider.dispose();
		if (expressionParameterDescriptorItemProvider != null) expressionParameterDescriptorItemProvider.dispose();
		if (booleanParameterDescriptorItemProvider != null) booleanParameterDescriptorItemProvider.dispose();
		if (enumerationParameterDescriptorItemProvider != null) enumerationParameterDescriptorItemProvider.dispose();
		if (enumerationItemProvider != null) enumerationItemProvider.dispose();
		if (enumerationLiteralItemProvider != null) enumerationLiteralItemProvider.dispose();
	}

}
